package com.xaioran.springmq.produce;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.jms.ConnectionFactory;
import javax.jms.Topic;

@SpringBootApplication
@EnableScheduling
public class MAInApp_Topic {
    public static void main(String args[]){
        SpringApplication.run(MAInApp_Topic.class,args);
    }
    @Bean
    public ConnectionFactory connectionFactory() {
        System.out.println("aaaaaaaaaaaaaaaaaaaaaa");
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
        connectionFactory.setBrokerURL("tcp://192.168.171.128:61616");
        connectionFactory.setUserName("admin");
        connectionFactory.setPassword("admin");
        return connectionFactory;
    }
    @Bean
    public JmsMessagingTemplate jmsMessageTemplate() {
        System.out.println("ccccccccccccc");
        return new JmsMessagingTemplate(connectionFactory());
    }
    @Bean
    public Topic topic(){
        return new ActiveMQTopic("boot-activemq-topic");
    }

}
